package com.dongdongshop.service.impl;

import com.dongdongshop.domain.model.TbItem;
import com.dongdongshop.domain.model.TbItemExample;
import com.dongdongshop.domain.vo.ItemVO;
import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.service.TbItemService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbItemServiceImpl implements TbItemService {
    @Autowired
    private TbItemMapper tbItemMapper;
    //批量增加商品表，sku中的数据
    @Override
    public void addItemManys(List<ItemVO> itemVoList) {
        tbItemMapper.addItemManys(itemVoList);
    }

    @Override
    public ItemVO getItemById(Long itemId) {
        TbItem tbItem = tbItemMapper.selectByPrimaryKey(itemId);
        ItemVO vo = new ItemVO();
        BeanUtils.copyProperties(tbItem,vo);
        return vo;
    }

    @Override
    public void updateByNum(List<ItemVO> itemVOList) {
        tbItemMapper.updateNumByKey(itemVOList);
    }

}
